/**
 * 
 */
package com.gmail.at.dengtooling.packets;

import com.gmail.at.dengtooling.util.Type;

/**
 * @author Deng Tooling
 * @version 1.0
 */
public class KeyExchange {
	public final static int PACKET_LENGTH_POSITION = 0;
	public final static int PADDING_LENGTH_POSITION = 4;
	public final static int MSG_CODE_POSITION = 5;
	
	private int			packetLength	= 0;
	private int			paddingLength;
	private int			msgCode;
	private Algorithms	algorithms;

	public KeyExchange(byte[] buffer) {
		// TODO Auto-generated constructor stub
		setPacketLength(buffer);
		paddingLength = buffer[PADDING_LENGTH_POSITION];
		msgCode = buffer[MSG_CODE_POSITION];
		algorithms = new Algorithms(buffer);
	}

	/**
	 * @return the packetLength
	 */
	public int getPacketLength() {
		return packetLength;
	}

	/**
	 * @param packetLength
	 *            the packetLength to set
	 */
	public void setPacketLength(byte[] buffer) {
		this.packetLength = Type.bytes2int(buffer, PACKET_LENGTH_POSITION);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "KeyExchange [packetLength=" + packetLength + ", paddingLength="
				+ paddingLength + ", msgCode=" + msgCode + ", algorithms="
				+ algorithms + "]";
	}

}
